#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>

typedef struct Node
{
	int data;
	struct Node* next;
}*node;

int main()
{
	node head = (node)malloc(sizeof(struct Node));
	head->next = NULL;
	node tail = head;
	/*for (int i = 0; i < 5; i++)
	{
		node n = (node)malloc(sizeof(struct Node));
		n->data = i + 1;
		n->next = head->next;
		head->next = n;
	}*/
	for (int i = 0; i < 5; i++)
	{
		node n = (node)malloc(sizeof(struct Node));
		n->data = i + 1;
		n->next = NULL;
		tail->next = n;
		tail = n;
	}

	node p = head;
	node p1 = head->next;
	node p2 = p1->next;

	while (p1->next)
	{
		p1->next = p;
		p = p1;
		p1 = p2;
		p2 = p1->next;
	}
	head->next = NULL;
	p1->next = p;

	while (p1->next)
	{
		printf("%d ", p1->data);
		p1 = p1->next;
	}

	return 0;
}